/* 
 * CurrentOptsBO.java
 *
 * Created on March 5, 2007, 4:22 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.byu.isys413.jjenkins.data;

import java.sql.Date;
import java.sql.Time;

 /**
 * The currentOpts Bo contains the employee and store that are working with the transaction
 * For control purposes this information is attached to each transaction. This class
 * also contains information about when the clerk was checked in and out. 
 *
 *</b >
 *
 * The class is represents the currentOpts business object. It is created
 * by the curretOptsDAO. It extends businessObject which contains the ID,
 * alreadyInDatabase and dirty. This class contains the attributes of the currentOpts
 * with all getters and setters and any functionality of the object. 
 * 
 * @author      Jeff Jenkins
 * @version     1.0
 * 
 */
public class CurrentOptsBO extends BusinessObject{
    
   private StoreBO store = null;
   private EmployeeBO employee = null;
   private Date time_in = null;
   private Date time_out  = null;
   
   
    
    /** Creates a new instance of CurrentOptsBO */
    public CurrentOptsBO() {
    }

    /**This method returns the store in this current opts
     *return: StoreBO*/
    
    public StoreBO getStore() {
        return store;
    }

    /**This method sets the store in this current opts
     *par: StoreBO*/
    
    public void setStore(StoreBO store) {
        this.store = store;
        setDirty(true);
    }

    /**This method returns the employee in this current opts
     *return: EmployeeBO*/
    
    public EmployeeBO getEmployee() {
        return employee;
    }

    /**This method sets the employee in this current opts
     *par: EmployeeBO*/    
    public void setEmployee(EmployeeBO employee) {
        this.employee = employee;
        setDirty(true);
    }
    
    /**This method returns the Time_in in this current opts
     *return: sql.Time*/
    
    public Date getTime_in() {
        return time_in;
    }
    
    
    /**This method sets the Time_in in this current opts
     *par: sql.Time*/
    
    public void setTime_in(Date time_in) {
        this.time_in = time_in;
        setDirty(true);
    }

    
    /**This method returns the Time_out in this current opts
     *return: sql.Time*/
        
    public Date getTime_out() {
        return time_out;
    }
    
    /**This method sets the Time_out in this current opts
     *par: sql.Time*/
    
    public void setTime_out(Date time_out) {
        this.time_out = time_out;
        setDirty(true);
    }
    
    public void SignIn(String emp, String sto) throws DataException{
        employee = EmployeeDAO.getInstance().read(emp);
        store = StoreDAO.getInstance().read(sto);
        time_in = new Date(System.currentTimeMillis());
        CurrentOptsDAO.getInstance().save(this);
        
        
    }
    
    public void SignOut() throws DataException{
        time_out = new Date(System.currentTimeMillis());
        CurrentOptsDAO.getInstance().save(this);
        
    }
}
